]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
St: Ensure to update entry hint visibility with IM preedit
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 11 Mar 2020 11:32:07 +0000 (12:32 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 11 Mar 2020 13:07:07 +0000 (14:07 +0100)
Commit 88ac339774 changed StEntry behavior so the text hint would
stay visible while focused, as long as the text buffer is empty.
However, IMs that use preedit still should count as "started typing",
while the text buffer is still officially empty.

To fix this, check on st_entry_update_hint_visibility() that there's
indeed no preedit buffer before showing the hint. We can't directly
listen to internal preedit buffer changes in ClutterText, so handle
preedit buffer updates through the ::cursor-changed signal that will
be indirectly emitted.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1084

src/st/st-entry.c

index 24fe7434c79a6216babbec49e72c236a834435a1..28dddc0537f3b93e55731ef1915f7f35b0eec571 100644 (file)
@@ -232,6 +232,7 @@ st_entry_update_hint_visibility (StEntry *self)
   StEntryPrivate *priv = ST_ENTRY_PRIV (self);
   gboolean hint_visible =
     priv->hint_actor != NULL &&
+    !clutter_text_has_preedit (CLUTTER_TEXT (priv->entry)) &&
     strcmp (clutter_text_get_text (CLUTTER_TEXT (priv->entry)), "") == 0;
 
   if (priv->hint_actor)
@@ -530,6 +531,13 @@ clutter_text_focus_out_cb (ClutterText  *text,
   clutter_text_set_cursor_visible (text, FALSE);
 }
 
+static void
+clutter_text_cursor_changed (ClutterText *text,
+                             StEntry     *entry)
+{
+  st_entry_update_hint_visibility (entry);
+}
+
 static void
 clutter_text_changed_cb (GObject    *object,
                          GParamSpec *pspec,
@@ -980,6 +988,9 @@ st_entry_init (StEntry *entry)
   g_signal_connect (priv->entry, "button-press-event",
                     G_CALLBACK (clutter_text_button_press_event), entry);
 
+  g_signal_connect (priv->entry, "cursor-changed",
+                    G_CALLBACK (clutter_text_cursor_changed), entry);
+
   g_signal_connect (priv->entry, "notify::text",
                     G_CALLBACK (clutter_text_changed_cb), entry);